<template>
  <ul>
    <li  v-for="(item, index) in modelValue" v-show="index < 5" :key="index">
      <div class="flag">
        <img v-if="index == 0" src="@/assets/data-overview/top-1.png" alt="">
        <img v-else-if="index == 1" src="@/assets/data-overview/top-2.png" alt="">
        <img v-else-if="index == 2" src="@/assets/data-overview/top-3.png" alt="">
        <b v-else>{{ index + 1 }}</b>
      </div>
      <dl>
        <dt>
          <b>{{ item.x }}</b>
          <span>{{ item.y }}</span>
        </dt>
        <dd :class="{normal: index>2}" :style="{ width: item.per * 100 + '%' }" />
        <dd  class="line-bg" />
      </dl>
    </li>
    <li v-if="modelValue.length==0" style="height: 218px;overflow:hidden;position:relative;">
  <img src="../../../assets/data-overview/empty.png" style="position:relative;top:50px;margin: 0 auto;height:100%;width: auto;" alt="">
    </li>
  </ul>
</template>

<script>
import { defineComponent } from "vue";

export default defineComponent({
  name: "TopList",
  props: {
    modelValue: {
      type: Array,
      default: () => []
    }
  },
  setup(props, { emit }) {

    return {

    };
  },
});
</script>

<style lang="scss" scoped>
dl,
dt,
dd {
  padding: 0;
  margin: 0;
}

ul {
  list-style: none;
  margin: 0;
  padding: 0;

  li {
    list-style: none;
    display: flex;
    & + li {
      margin-top: 20px;
    }
    .flag {
      padding-top: 3px;
      img {
        width: 17px;
        height: 20px;
      }

      b {
        display: inline-block;
        width: 18px;
        height: 18px;
        background: #2E69EB;
        border-radius: 50%;
        font-size: 14px;
        color: #fff;
        text-align: center;
      }
    }

    dl {
      width: calc(100% - 30px);
      margin-left: calc(30px - 20px);
      position: relative;
      dd {
        width: 100%;
        height: 6px;
        background: linear-gradient(270deg, #FFA400 0%, #FFD692 100%);
        border-radius: 4px;
        &.normal {
          background: linear-gradient(144deg, #2798FF 0%, #2E69EB 100%);
        }
        &.line-bg {
          width: 100%;
          background: rgba(0,0,0,0.05);
          position: absolute;
          bottom: 0;

        }
      }

      dt {
        margin-bottom: 2px;
        overflow: hidden;
        color: #3C475D;
        font-size: 13px;
        font-weight: 400;

        b {
          float: left;
          font-weight: 400;
        }

        span {
          float: right;
        }
      }
    }
  }
}
</style>
